let arr = [1,2,3,3,2,1,4,5];

function uniq(arr){
  let set = new Set(arr);
  return [...set];
}

console.log(uniq(arr));